<template>
  <div>
    <el-table
      :data="cateList"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      height="500"
      border
      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
    >
      <el-table-column
        prop="catename"
        label="分类名称"
        sortable
        width="180"
      ></el-table-column>

        <el-table-column label="状态" sortable width="180">
        <template slot-scope="scope">
          <el-button
            size="mini"
            plain
            :type="scope.row.status ? 'success' : 'warning'"
          >
            {{ scope.row.status == 1 ? "启用" : "禁用" }}
          </el-button>
        </template>
      </el-table-column>

      <el-table-column label="操作">
        <!-- 作用域插槽 将每一行循环的item数据通过scope返回给使用者 -->
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: ["cateList"],

  data() {
    return {
    
    };
  },
  methods: {
    //1.编辑菜单数据  兄弟组件传值 通过子传父 父亲再赋给表单
    handleEdit(index, row) {
      //this.$emit ('父亲传递的自定义事件名字','传递的数据')
      this.$emit("edit", { index, row });
    },
    //2.删除菜单数据
    handleDelete(index, row) {
      this.$emit("remove", { index, row });
    },
  },
};
</script>

<style scoped>
</style>
